package pers.course.week3;

import java.util.Scanner;

public class SumOfDigits {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int nums = in.nextInt();
        int[] sum = new int[nums];
        for (int i = 0; i < nums; i++) {
            String num = in.next();
            char[] arr = num.toCharArray();
            int j = 0;
            if(arr[0] == '-') {
                j = 1;
            }
            for (; j < arr.length; j++) {
                sum[i] += arr[j]-'0';
            }
        }
        for (int k = 0; k < nums; k++) {
            System.out.println(sum[k]);
        }
    }
}
